<?php
$xtpl = new XTemplate("modules/home/contact_task.htm");
//--
$POST = $_POST;

if($_POST[type] == 'NEW'){	
		$POST[bc_firstname]=$_POST['txtfirstname'];
		$POST[bc_lastname]=$_POST['txtlastname'];
		$POST[bc_mail]=$_POST['txtemail'];
		$POST[bc_address]=$_POST['txtaddress'];
		$POST[bc_phone]=$_POST['txtphone'];
		$POST[bc_comment]=$_POST['description'];
		$POST[bc_datetime] = date('Y-m-d h:i:s');
	//--
		$DB->DBInsert('contact', $POST);
	//--
	$GUI->redir("?mod=home&act=contact");
}
elseif($_POST[type] == 'EDIT'){
		$POST[bc_firstname]=$_POST['txtfirstname'];
		$POST[bc_lastname]=$_POST['txtlastname'];
		$POST[bc_mail]=$_POST['txtemail'];
		$POST[bc_address]=$_POST['txtaddress'];
		$POST[bc_phone]=$_POST['txtphone'];
		$POST[bc_comment]=$_POST['description'];
	//--
	$DB->DBUpdate('contact', $POST, "WHERE bc_id = '".$POST['id']."'");
	//--
	$GUI->redir("?mod=home&act=contact");
}
//--
//--
if($_GET[id] != ''){
	$row = $DB->FetchData('contact','*',"WHERE bc_id='".$_GET[id]."'");
	$row[type] = 'EDIT';
	$row[id] = $row['bc_id'];
	$row[bc_firstname]=stripslashes($row['bc_firstname']);
	$row[bc_lastname]=$row['bc_lastname'];
	$row[bc_mail] = $row['bc_mail'];
	$row[bc_address] = $row['bc_address'];
	$row[bc_phone] = $row['bc_phone'];
	$row[bc_comment] = $row['bc_comment'];
	$row[bc_datetime] = $row['bc_datetime'];
	
}else{
	$row[type] = 'NEW';
}
$_FCKeditor = new FCKeditor("description");
$_FCKeditor->BasePath = $siteFCKeditorPath;
$_FCKeditor->Width = '95%';
$_FCKeditor->Height = '450';
$_FCKeditor->Value = stripslashes($row['bc_comment']);

//--
//--
$xtpl->assign("write",$row);
//--
//--
$waypathlink = '&raquo;&nbsp;<a href="?mod=home&act=contact" class="waypath">Contact Management</a>:&nbsp;'.$row[type];
$xtpl_main->assign("waypathlink",$waypathlink);
//--
//--
$save_button = $GUI->button_ren("Save","javascript: doSavenews();");
$xtpl->assign("save_button",$save_button);
//--
$cancel_button = $GUI->button_ren("Cancel","javascript: add('?mod=home&act=contact');");
$xtpl->assign("cancel_button",$cancel_button);

?>